package SetExample;

import java.util.HashMap;

public class MultiThreadHashMap {
    public static void main(String[] args) throws InterruptedException {

        MyTicket myTicket=new MyTicket();
        Thread t1=new Thread(myTicket,"t1");
        Thread t2=new Thread(myTicket,"t2");
        t1.start();
        t2.start();
        Thread.sleep(5000);
        myTicket.printMap();
    }
}

class MyTicket implements Runnable{

    private int ticket=100;
    private HashMap<Integer,Integer> map=new HashMap<>();

    @Override
    public void run() {
        for (int i = 1; i<=1000; i++) {
             map.put(i,i);
        }
    }

    public void printMap(){
        System.out.println(map);
    }
}


